package com.taiyi.renaissancemall.ui.classification.goodlist;

import android.content.Intent;
import android.graphics.Paint;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.taiyi.renaissancemall.R;
import com.taiyi.renaissancemall.ui.main.goodsdetail.GoodsDetailActivity;

import java.util.List;

public class GoodList2Adapter extends BaseQuickAdapter<GoodListBean.ComlistBean, BaseViewHolder> {
    public GoodList2Adapter(int layoutResId, @Nullable List<GoodListBean.ComlistBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodListBean.ComlistBean item) {
        ImageView img = (ImageView) helper.getView(R.id.iv);
        Glide.with(mContext).load(item.smallimgurl).into(img);
        helper.setText(R.id.productNameTv, item.name);
        helper.setText(R.id.bvPriceTv, item.hybvprice + "BV");
        helper.setText(R.id.priceTv, "￥"+item.price);
//        helper.setText(R.id.sanPriceTv,"￥"+ item.sanfprice);
//        TextView sanPriceTv = helper.getView(R.id.sanPriceTv);
//        sanPriceTv.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        helper.setText(R.id.memberPriceTv, "￥"+item.hyprice);
        ConstraintLayout constraintLayout = (ConstraintLayout) helper.getView(R.id.item_layout);
        constraintLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //跳转商品详情
                Intent intent = new Intent(mContext, GoodsDetailActivity.class);
                intent.putExtra("commodityId", item.commodityid);
                mContext.startActivity(intent);
            }
        });
    }
}
